﻿@{
    ViewBag.Title = "ItemSales";

    Layout = "~/Views/Shared/_Index.cshtml";
}
<script>
    $(function () {
        gridListData([]);
        $(".moreInfo").hide();
        $("#disBtn").click(function () {
            $(".moreInfo").fadeToggle();//.show();
        });

        $("#dm").change(function () {
            var val = this.value;
            switch (val) {
                case "0":
                    $("#fl").val("物理因子治疗");
                    $("#zfy").val("5");
                    $("#dj").val("5");
                    break;
                case "1":
                    $("#fl").val("运动、作业、言语");
                    $("#zfy").val("60");
                    $("#dj").val("60");
                    break;
                case "2":
                    $("#fl").val("针法、灸法、罐法");
                    $("#zfy").val("3");
                    $("#dj").val("3");
                    break;
                default:
                    $("#txtsfbz").val("");
                    $("#txtzfy").val("");
                    $("#txtzlsc").val("");
                    break;
            }
        });

        $("#sl").blur(function () {
            var $this = Number($(this).val());
            dj = $("#dj").val();
            $("#zfy").val(dj * Number($this));
        });

        $("#sl,#xs,#ks,#mc").keydown(function (event) {
            if ((event.keyCode || event.which) == 13) {
                newtouch_globalevent_f6();
            }
        });
    });

    function newtouch_globalevent_f6() {
        var $gridList = $("#gridList");
        var mydata = [{ id: "1", sfxm: $("#dm").find("option:selected").text(), fl: $("#fl").val(), xs: $("#xs").val(), dj: $("#dj").val(), sl: $("#sl").val(), zfbl: "0.0", zfy: $("#dj").val() * $("#sl").val(), mc: $("#mc").val() }]
        ;
        gridListData(mydata);
        $gridList.jqGrid('setGridParam', "unWritten:'false'").trigger("reloadGrid");
        $("#total").html("￥" + $("#gridList").getCol('zfy', false, 'sum'));
        clearJZInfo();
    }

    function newtouch_globalevent_f7() {
        var rowid = $('#gridList').jqGrid('getGridParam', 'selrow');
        EditSelectItem(rowid);
    }

    function newtouch_globalevent_f8() {
        var rowid = $('#gridList').jqGrid('getGridParam', 'selrow');
        $("#gridList").jqGrid('delRowData', rowid);
    }
    //清除记账信息
    function clearJZInfo() {
        newtouch_globalevent_f4(null, {
            container: "#HosBasicInfo",
            inner: false
        });
    }

    //绑定grid
    function gridListData(mydata) {
        var $gridList = $("#gridList");
        $gridList.newtouchLocalDataGrid({
            height: $(window).height() - 345,
            shrinkToFit: true,
            footerrow: true,
            colModel: [
                { label: "主键", name: "patid", hidden: true },
                { label: '收费项目', name: 'sfxm', width: 100, align: 'left', editor: "text" },
                  { label: '分类', name: 'fl', width: 300, align: 'left', editor: "text" },
                { label: '销售人员', name: 'xs', width: 300, align: 'left', editor: "text" },
                { label: '单价', name: 'dj', width: 100, align: 'left', editor: "text" },
                { label: '数量', name: 'sl', width: 100, align: 'left', editor: "text" },
                { label: '自付比例', name: 'zfbl', width: 100, align: 'left', editor: "text" },
                { label: '总金额', name: 'zfy', width: 100, align: 'left', editor: "text" },
            { label: '患者姓名', name: 'mc', width: 300, align: 'left', editor: "text" }
            ],
            ondblClickRow: function (rowid) {
                EditSelectItem(rowid);
            }
        });

        for (var i = 0; i <= mydata.length; i++) {
            $gridList.jqGrid('addRowData', i + 1, mydata[i]);
        }
    }

    function EditSelectItem(rowid) {
        var rowData = $("#gridList").jqGrid("getRowData", rowid);
        $('#form1').formSerialize(rowData);
        switch (rowData.sfxm) {
            case "红外线治疗":
                ddlval = "0";
                break;
            case "超声药物透入治疗":
                ddlval = "1";
                break;
            case "普通针刺（体针）":
                ddlval = "2";
                break;
            default:
                ddlval = "===请选择===";
                break;
        }
        $("#dm").val(ddlval);
        $("#gridList").jqGrid('delRowData', rowid);
    }
    function getMorePatientInfo() {
        $.modalOpen({
            id: "Form",
            title: "更多信息",
            url: "/TherapeutistCompleteList/MorePatientInfo",
            width: "900px",
            height: "260px",
            callBack: function (iframeId) {
                top.frames[iframeId].submitForm();
            }
        });
    }
</script>
<style>
    span {
        color: red;
    }
</style>
<form id="form1" style="margin-left:20px;">
    <div class="rows" id="HosBasicInfo">
        <div class="panel panel-default" style="margin-bottom: 0;">
            <div class="panel-heading">
                记账信息
            </div>
            <table class="form" style="width:98%;margin-top:10px;">
                <tr>
                    <td class="formTitle">收费项目:<span>*</span></td>
                    <td class="formValue">
                        <select id="dm" class="form-control">
                            <option value="">===请选择===</option>
                            <option value="0">红外线治疗</option>
                            <option value="1">超声药物透入治疗</option>
                            <option value="2">普通针刺（体针）</option>
                        </select>
                    </td>

                    <td class="formTitle">分类:</td>
                    <td class="formValue"><input type="text" id="fl" class="form-control newtouch_Readonly" /></td>
                    <td class="formTitle">销售人员:</td>
                    <td class="formValue"><input type="text" id="xs" class="form-control" /></td>
                    <td class="formTitle">科室:</td>
                    <td class="formValue">
                        <input type="text" id="ks" class="form-control" />
                    </td>
                </tr>
                <tr>
                    <td class="formTitle">单价:</td>
                    <td class="formValue"><input type="text" id="dj" class="form-control newtouch_Readonly" /></td>

                    <td class="formTitle">数量:</td>
                    <td class="formValue"><input type="text" id="sl" class="form-control" value="1" /></td>
                    <td class="formTitle">总金额:</td>
                    <td class="formValue"><input type="text" id="zfy" class="form-control newtouch_Readonly" /></td>
                    <td class="formTitle">患者姓名:</td>
                    <td class="formValue"><input type="text" id="mc" class="form-control" /></td>

                </tr>
            </table>
        </div>

        @Html.Partial("_BottomButtonsView", new Newtouch.HIS.Web.Core.Models.BottomButtonViewModel
   {
       ShowKeyList = new int[] { 6, 7, 8 },
       F6Text = "添加",
       F7Text = "修改",
       F8Text = "删除"
   })
    </div>
</form>
<div class="gridPanel" style="margin-top: 50px">
    <table id="gridList"></table>
</div>
<div class="rows" style="" id="HosBasicInfo">
    <div class="panel panel-default">
        <div class="panel-heading">
            应收
        </div>
        <table class="form">
            <tr>
                <td class="formTitle">应收款</td>
                <td class="formValue">
                    <span style="color:red;font-size:large;"><strong id="total">￥150.00</strong></span>
                </td>
                <td class="formTitle">实收款</td>
                <td class="formValue">
                    <input type="text" id="txtINPUTCODE" class="form-control" />
                </td>
                <td class="formTitle">找零</td>
                <td class="formValue"></td>
                <td class="formTitle"></td>
                <td class="formValue"></td>
            </tr>
        </table>
    </div>
</div>
@Html.Partial("_BottomButtonsView", new Newtouch.HIS.Web.Core.Models.BottomButtonViewModel
{
    ShowKeyList = new int[] { 4, 9 },
    F9Text = "保存"
})
